#this is not necessary but for those who do not like to use new/delete
#DEFS=-DUSE_MALLOC 
CXX=/soft/apps/darshan/bin/default/mpixlcxx_r
CC=xlc_r
FC=xlf_r

#include compiler flags determined by the CXX
#include flags.make
CXXFLAGS=-qarch=450d  -qsmp=omp -qthreaded -qkeyword=restrict -qstrict \
	 -qhot -qnoeh -qsuppress=1540-1090:1540-1088 \
	 -O3 -qmaxmem=-1  -qlargepage -qprefetch 

## where mpi/communictor.h 
SRCDIR=../src
INCLUDE=-I. -I$(SRCDIR)

#DEFS+= -DHAVE_OPENMP 
DEFS+= -DHAVE_MPI -DHAVE_OPENMP -DMPICH_SKIP_MPICXX -DAPPNAMESPACE=qmcplusplus

%.o : %.cpp 
	$(CXX) $(DEFS) $(CXXFLAGS) $(INCLUDE) -c $< -o $@

.PHONY: all
all: fft3d_comm fft3d_comm_copy

### common objects 
cobjs = communicator.o
#cfiles = mambo.hpp

fft3d_comm : $(SRCDIR)/fft3d/fft3d_comm.cpp $(SRCDIR)/fft3d/fft3d_engine_a2a.hpp communicator.o
	$(CXX) $(DEFS) $(CXXFLAGS) $(INCLUDE) $(LDFLAGS) -o fft3d_comm $(SRCDIR)/fft3d/fft3d_comm.cpp communicator.o

fft3d_comm_copy : $(SRCDIR)/fft3d/fft3d_comm.cpp $(SRCDIR)/fft3d/fft3d_engine_a2a.hpp communicator.o
	$(CXX) $(DEFS) -DDOSTUFF $(CXXFLAGS) $(INCLUDE) $(LDFLAGS) -o fft3d_comm_copy $(SRCDIR)/fft3d/fft3d_comm.cpp communicator.o

# utility libraries
communicator.o : $(SRCDIR)/mpi/communicator.cpp
	$(CXX) $(DEFS) $(CXXFLAGS) $(INCLUDE) -c $(SRCDIR)/mpi/communicator.cpp -o communicator.o

.PHONY: clean
clean: 
	rm -rf *.o fft3d_*
